<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>javascript继承-Class实现继承</title>
</head>

<body>
  <script>
    /**
     * Class实现继承：使用ES6中的Class,extends 实现继承
     * 
     * */
    //定义父类
    class PersonModel {
      constructor(name, skill) {
        this.name = name;
        this.skill = skill;
      }

      introduce() {
        console.log(`我叫:${this.name}， 技能包含${this.skill.join('、')}`);
      }
    };
    // 通过extends关键字实现继承
    class Person extends PersonModel {
      constructor(name, skill) {
        super(name, skill);
      }
    };

    let person1 = new Person('周杰伦', ['唱歌', '作曲']);
    let person2 = new Person('于谦', ['抽烟', '喝酒', '烫头']);

    console.log('person1 与 person2的名字：', person1.name + '___' + person2.name);
    person1.introduce();
    person2.introduce();
  </script>
</body>

</html>